﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dapper_Core.BLL.Impl;
using Dapper_Core.Model;
using Dapper_Core.Table;
using Microsoft.AspNetCore.Mvc;

namespace Dapper_Core.Web.Areas.Sys.Controllers
{
    public class Sys_DepartmentController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        public IActionResult GetDept1(string dept1Code, bool hasExtra, int? isYanfa = null, int? isHistory = null)
        {
            Sys_DepartmentBusiness service = new Sys_DepartmentBusiness();
            List<Sys_Department> deptManager = service.GetDept1List(isYanfa, isHistory, hasExtra);
            return Json(deptManager);
        }

        public IActionResult GetDept2(string dept1Code, bool hasExtra, int? isYanfa = null, int? isHistory = null)
        {
            Sys_DepartmentBusiness service = new Sys_DepartmentBusiness();
            List<Sys_Department> deptManager = service.GetDept2List(dept1Code, isYanfa, isHistory, hasExtra);
            return Json(deptManager);
        }

        public IActionResult GetDept3(string dept2Code, bool hasExtra, int? isYanfa = null, int? isHistory = null)
        {
            Sys_DepartmentBusiness service = new Sys_DepartmentBusiness();
            List<Sys_Department> deptManager = service.GetDept3List(dept2Code, isYanfa, isHistory, hasExtra);
            return Json(deptManager);
        }

        public IActionResult GetManagerAndId(string dept1Code, string dept2Code, string dept3Code)
        {
            Sys_DepartmentBusiness service = new Sys_DepartmentBusiness();
            Sys_Department department = service.GetModel(dept1Code, dept2Code, dept3Code);
            return Json(department);
        }
    }
}